#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

int getMissing(int num[], int size)
{
    vector<int> arr(size, 0);
    int base = 1;

    for (int i = 0; i < size; i++) {
        if (num[i] < 0 || num[i] >= size)
            continue;
        if(num[num[i]-1] != num[i]) {
            int tmp = num[num[i]-1];
            num[num[i]-1] = num[i];
            num[i] = tmp;
            i--;
        }
    }

    for (int i = 0; i < size; i++) 
        if (num[i] != i+1)
            return i+1;
    return size+1;
}


int main(int argc, char **argv)
{

    cout << "-----------------Test 1--------------------" << endl;
    int test1[] = {1, 1, 0, -1, -2 };
    cout << "Missing " << getMissing(test1, sizeof(test1)/sizeof(int)) << endl;


    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
